package com.acwing.partition35;

import java.io.*;

/**
 * @author `RKC`
 * @date 2022/3/13 9:18
 */
public class AC3418杨辉三角形_二分 {

    private static int n;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        n = Integer.parseInt(reader.readLine());
        //枚举斜行，并对每一个斜行内部进行二分查找
        for (int i = 16; i >= 0; i--) {
            if (check(i)) break;
        }
        writer.flush();
    }

    private static boolean check(int k) throws IOException {
        long l = k * 2L, r = Math.max(l, n);
        while (l < r) {
            long mid = l + r >> 1;
            if (c(mid, k) >= n) r = mid;
            else l = mid + 1;
        }
        if (c(l, k) != n) return false;
        writer.write((l * (l + 1) / 2 + k + 1) + "\n");
        return true;
    }

    private static long c(long a, long b) {
        long res = 1;
        for (long i = a, j = 1; j <= b; j++, i--) {
            res = res * i / j;
            if (res > n) return res;
        }
        return res;
    }
}
